package com.example.demo;


import org.springframework.jdbc.core.JdbcTemplate;

public class AccountImpl implements AccountDao{

    private JdbcTemplate jdbcTemplate;

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

//    public JdbcTemplate getJdbcTemplate() {
//        return jdbcTemplate;
//    }

    @Override
    public void transfer(String outUser, String inUser, Double money) {
       this.jdbcTemplate.update("update account set balance = balance + ?" + "where username = ?",money,inUser);
        this.jdbcTemplate.update("update account set balance = balance - ?" + "where username = ?",money,outUser);
    }
}
